<?php
include_once 'model/slider/process.php';
include_once 'module/controls.php';
include_once 'model/user/user_create.php';
$c = new controls();
$slider = new slider();
$user = new users();
$fillByName = $user->FillOneByName($_SESSION);
$result = $slider->FillAll();
$level_decode = json_decode($fillByName["level"], true);
?>
<div id="content">
    <?php if ($level_decode["admin"] != "" || $level_decode["create"] != "") { ?>
        <span class="bglink"><a class="link" href="<?= $url["home"] ?>/menu/slider-create"><?php echo $phrase["slider_create"] ?></a></span>
    <?php } ?>
    <table id="example" cellspacing="1" class="display">
        <thead>
            <tr>
                <th width="35%"><?php echo $phrase["banner_url"] ?></th>
                <th><?php echo $phrase["slider_title"] ?></th>
                <th><?php echo $phrase["slider_description"] ?></th>
                <td class="status" width="80px"></td>
            </tr>
        </thead>
        <tbody>
        <?php
        while ($rows = mysql_fetch_array($result)) {
            $i++;
            if ($i % 2) {
                ?>
                <tr class="gradeC odd">
                    <td><img src="<?php echo $rows["banner_url"] ?>" width="200" height="100"/></td>
                    <td><?php echo $rows["title"] ?></td>
                    <td><?php echo $rows["description"] ?></td>
                    <td class="first">
                        <?php if ($level_decode["admin"] != "" || $level_decode["update"] != "") { ?>
                            <a href="<?= $url["home"] ?>/menu/sliderupdate/id/<?php echo $rows["banner_id"] ?>">
                                <image src="<?= $url["home"] ?>/images/icons/edit-icon.gif"/>
                            </a>
                        <?php } ?>
                        <?php if ($level_decode["admin"] != "" || $level_decode["update"] != "" && $level_decode["delete"]) { ?>
                            | 
                        <?php } ?>
                        <?php if ($level_decode["admin"] != "" || $level_decode["delete"] != "") { ?>
                            <a href="<?= $url["home"] ?>/menu/sliderdelete/id/<?php echo $rows["banner_id"] ?>" onclick="return confirm('Bạn có chắc chắn muốn xóa không.');">
                                <image src="<?= $url["home"] ?>/images/icons/b_drop.png"/>
                            </a>
                        <?php } ?>
                </tr>
            <?php } else { ?>
                <tr class="gradeC even">
                    <td><img src="<?php echo $rows["banner_url"] ?>" width="200" height="100"/></td>
                    <td><?php echo $rows["title"] ?></td>
                    <td><?php echo $rows["description"] ?></td>
                    <td class="last">
                        <?php if ($level_decode["admin"] != "" || $level_decode["update"] != "") { ?>
                            <a href="<?= $url["home"] ?>/menu/sliderupdate/id/<?php echo $rows["banner_id"] ?>">
                                <image src="<?= $url["home"] ?>/images/icons/edit-icon.gif"/>
                            </a>
                        <?php } ?>
                        <?php if ($level_decode["admin"] != "" || $level_decode["update"] != "" && $level_decode["delete"]) { ?>
                            | 
                        <?php } ?>
                        <?php if ($level_decode["admin"] != "" || $level_decode["delete"] != "") { ?>
                            <a href="<?= $url["home"] ?>/menu/sliderdelete/id/<?php echo $rows["banner_id"] ?>" onclick="return confirm('Bạn có chắc chắn muốn xóa không.');">
                                <image src="<?= $url["home"] ?>/images/icons/b_drop.png"/>
                            </a>
                        <?php } ?>
                    </td>
                </tr>
            <?php } ?>
        <?php } ?>
        </tbody>
        <tfoot>
            <tr>
                <th colspan="4"></th>
            </tr>
        </tfoot>
    </table>
</div>
<script type="text/javascript">
    $(document).ready(function() {
        $('#example').dataTable({
            "sPaginationType": "full_numbers"
        });
    });
</script>